package com.kaka.bus.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kaka.bus.AppCenter;
import com.kaka.bus.R;
import com.kaka.bus.bean.BorrowDeteil;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by zhangqi on 2016/11/2.
 */

public class BorrowDeteilAdapter extends BaseQuickAdapter<BorrowDeteil.PlanListBean,BaseViewHolder> {


    public BorrowDeteilAdapter(int layoutResId, @Nullable List<BorrowDeteil.PlanListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BorrowDeteil.PlanListBean item) {
        SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Long time=new Long(item.getRepayDate());
        String d = format.format(time);
        helper.addOnClickListener(R.id.item_view);
        helper.setText(R.id.item_borrowdeteil_term,item.getTerm()+"/"+this.getData().size()+"期")
        .setText(R.id.item_borrowdeteil_money, AppCenter.mDf.format(item.getSurplusAmount()))
        .setText(R.id.item_borrowdeteil_money1,AppCenter.mDf.format(item.getRentalAmount()))
        .setText(R.id.item_borrowdeteil_money2,AppCenter.mDf.format(item.getPenalty()))
        .setText(R.id.item_borrowdeteil_money3, AppCenter.mDf.format(item.getPaidAmount()))
        .setText(R.id.item_borrowdeteil_time,d);
        if (item.getStatus()==0){
            helper.setText(R.id.item_borrowdeteil_status,"待付款");
        }else if (item.getStatus()==1){
            helper.setText(R.id.item_borrowdeteil_status,"已逾期");
        }else if (item.getStatus()==2){
            helper.setText(R.id.item_borrowdeteil_status,"正常结清");
        }else if (item.getStatus()==3){
            helper.setText(R.id.item_borrowdeteil_status,"逾期结清");
        }

    }
}
